<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8"/>
    <title></title>
    <meta name="renderer" content="webkit"/>
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
    <meta name="viewport"
          content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0"/>
    <link rel="stylesheet" href="/layuiadmin/layui/css/layui.css" media="all"/>
    <link rel="stylesheet" href="/layuiadmin/style/admin.css" media="all"/>
    <style>
        .layui-form-item .layui-input-inline {
            width: 150px;
        }
    </style>
</head>
<body>
<div class="layui-fluid">
    <div class="layui-card">
        <div class="layui-tab layui-tab-brief">
            <ul class="layui-tab-title layui_tab_title">
                <li class="layui-this"><a href="javascript:void(0);">活动列表</a></li>
                <li ><a href="/admin/rotary_table/conf">奖品列表</a></li>
                <li><a href="/admin/rotary_table/history">领取记录</a></li>
            </ul>
        </div>

        <form class="layui-form" id="sbumitForm">
            <div class="layui-form layui-card-header layuiadmin-card-header-auto">
                <div class="layui-form-item">
                    <div class="layui-inline ">
                        <div class="layui-input-inline">
                            <div class="layui-btn" onclick="add()">
                                新建活动
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </form>
        <div class="layui-card-body layui-table-body layui-table-main">
            <table id="demo" lay-filter="demo"></table>
        </div>
    </div>
</div>

<script src="/layuiadmin/layui/layui.js"></script>
<script>
    layui.config({
        base: "/layuiadmin/" //静态资源所在路径
    }).extend({
        index: "lib/index", //主入口模块
    }).use(["table", 'form'], function () {
        $ = layui.jquery, form = layui.form, table = layui.table;
        table.render(table_conf());
    });

    function table_conf() {
        return {
            elem: '#demo',
            id: '#demo',
            url: '/admin/rotary_table/index',
            page: {
                curr: 1   //默认从第一页开始搜索
            },
            method: "get",
            //where: $("#sbumitForm").serialize(),
            limit: 20,
            limits: [20, 30, 50, 100],
            text: {
                none: '暂无相关数据！'//默认无数据
            },
            response: {
                statusName: 'code', //数据状态的字段名称，默认：code
                statusCode: 0,//成功的状态码，默认：0
                msgName: 'msg', //状态信息的字段名称，默认：msg
                countName: 'count', //数据总数的字段名称，默认：count
                dataName: 'list', //数据列表的字段名称，默认：data
            },
            cols: [[
                {field: 'id', width: 70, title: 'ID', align: 'center'},
                {field: 'name', width: 150, title: '活动标题', align: 'center'},
                {field: 'introduce', width: 150, title: '活动介绍', align: 'center'},
                {
                    field: '', width: 120, title: 'PC背景图', align: 'center', templet: function (item) {
                        return '<div class="layui-table-cell laytable-cell-1-0-4"><img style="display: block;margin:0px auto; height: 100%;" src="' + item.pc_bg_pic + '"></div>'
                    }
                },
                {
                    field: '', width: 120, title: 'APP背景图', align: 'center', templet: function (item) {
                        return '<div class="layui-table-cell laytable-cell-1-0-4"><img style="display: block;margin:0px auto; height: 100%;" src="' + item.app_bg_pic + '"></div>'
                    }
                },
                {field: 'rule_desc', width: 160, title: '活动规则', align: 'center'},
                {
                    field: '', width: 110, title: '参与用户', align: 'center', templet: function (item) {
                        switch (item.join_user_type) {
                            case 0:
                                return '全部';
                            case 1:
                                return '贵族';
                            case 2:
                                return '普通';
                        }

                        return '-';
                    }
                },
                {field: 'diamond_cost', width: 130, title: '宝石抽奖/次', align: 'center'},
                {field: 'gold_cost', width: 130, title: '钻石抽奖/次', align: 'center'},
                {field: 'act_st_time', width: 160, title: '开始时间', align: 'center'},
                {field: 'act_ed_time', width: 160, title: '结束时间', align: 'center'},
                {field: 'status_text', width: 110, title: '状态', align: 'center'},
                {field: 'operator', width: 160, title: '操作人', align: 'center'},
                {
                    field: '', title: '操作', width: 160, align: 'center', fixed: 'right', templet: function (item) {
                        return '<a class="layui-btn layui-btn-xs" onclick="edit(' + item['id'] + ')"><i class="layui-icon"></i>编辑</a>' +
                            '<a class="layui-btn layui-btn-xs" onclick="prize(' + item['id'] + ')" style="background-color: #1E9FFF"><i class="layui-icon"></i>奖品配置</a>';
                    }
                },
            ]],
            done: function (res, curr, count) {
                res.list.forEach(function (item, index) {

                });
            },
        };
    }

    /*添加*/
    function add() {
        layer.open({
            type: 2,
            title: ["添加", 'font-size:16px'],
            content: '/admin/rotary_table/add',
            area: ['680px', '760px'],
            //offset: '0px',
        });
    }

    function edit(id) {
        layer.open({
            type: 2,
            title: ["编辑", 'font-size:16px'],
            content: '/admin/rotary_table/edit?id=' + id,
            area: ['780px', '760px'],
            //offset: '0px',
        });
    }

    function prize(id) {
        layer.open({
            type: 2,
            title: ["奖品配置", 'font-size:16px'],
            content: '/admin/rotary_table/prize?id=' + id,
            area: ['900px', '650px'],
            //offset: '0px',
        });
    }

</script>
</body>
</html>
